<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="穷在闹市" />
		<!-- 作者 -->
		<meta name="revised" content="穷在闹市.v3, 2019/05/01" />
		<!-- 定义页面的最新版本 -->
		<meta name="description" content="网站简介" />
		<!-- 网站简介 -->
		<meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
		<title>七星级酒店</title>

		<!-- 公共样式 开始 -->
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/iconfont.css">
		<script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="../../css/jquery.mCustomScrollbar.css">
		<script src="../../framework/jquery-ui-1.10.4.min.js"></script>
		<script src="../../framework/jquery.mousewheel.min.js"></script>
		<script src="../../framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->
		
		<style>
			.layui-form-label{
				width: 100px;
			}
			.layui-input-block{
				margin-left: 130px;
			}
			.layui-form{
				margin-right: 30%;
			}
		</style>
		<!-- leyui -->
			<script type="text/javascript">
			function messageBox(mes){
			    layui.use('layer', function(){
			      var layer = layui.layer;
			      layer.msg(mes, {icon: 4});
			    });
			   }
			</script>
			<!-- 加上事件 -->
				<script type="text/javascript">
				
					$(function(){
						$("#activeName").blur(checkactiveName);
						
					
					})
					
				function checkactiveName(){
						var activeName=$("#activeName").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
						if(activeName!="")
						{
							$.ajax({
								url:"/hotelManagement/AdminActiveServlet?action=activeName",//要访问的servlet
								type:"post",//传输的（方式） 
								async:false,//线程（类似）
								data:"activeName="+activeName,//传输的方式（）
								success:function(mes){
									if(mes!="null")//查到数据
									{
										
										c = JSON.parse(mes);
										
					
										$("#activeName").val(c.title);	
											
										$("#activePrice").val(c.price);
										$("#activeTimeStart").val(c.startTime);
										$("#activeTimeEnd").val(c.endTime);
										$("#activeText").val(c.content);
									}
									
								}
								
								
							});//ajax end
						}
					}
				
				</script>
	</head>

	<body>
	
		<div class="cBody">
			<form id="addForm" class="layui-form" method="post" action="/hotelManagement/AdminActiveServlet?action=activeServlet">
				<div class="layui-form-item">
					<label class="layui-form-label"  >活动名称</label>
					<div class="layui-input-block">
						<input type="text" name="goodsName"  id="activeName" required lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				<!--  end-->
				<div class="layui-form-item">
					<label class="layui-form-label" >活动图片</label>
					<input type="file" name="picture" id="goodsPic">
					<!-- <div class="layui-upload-drag" id="goodsPic" name="picture">
					  <i class="layui-icon"></i>
					  <p id="goodsPi">点击上传，或将文件拖拽到此处</p>
					</div> -->
					</input>
					
				</div>
				<!-- 加上事件 -->
				<script type="text/javascript">
					$(function(){
						$("#goodsPi").click(checkgoodsPi)
						var activeName=$("#goodsPi").val();
					
					})
				function checkgoodsPi(){
						var activeName=$("#goodsPi").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script>
				<!--  end-->
			<!-- 	<div class="layui-form-item">
					<label class="layui-form-label" >管理员名字</label>
					<div class="layui-input-block">
						<input type="text" name="company"  id="adminName" required lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
			 -->
				
				<div class="layui-form-item">
					<label class="layui-form-label" for="activePrice">参考价格</label>
					<div class="layui-input-block">
						<input type="text" name="price"   id="activePrice"  required lay-verify="required|number" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!-- 加上事件 -->
				<script type="text/javascript">
					$(function(){
						$("#activePrice").blur(checkactivePrice)
						var activeName=$("#activePrice").val();
					
					})
				function checkactivePrice(){
						var activeName=$("#activePrice").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script>
				<!--  end-->
				<div class="layui-form-item">
					<label class="layui-form-label" for="activeTime">活动开始时间</label>
					<div class="layui-input-block">
						<input type="text" name="password"  id="activeTimeStart" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" for="activeTime">活动结束时间</label>
					<div class="layui-input-block">
						<input type="text" name="passwords"  id="activeTimeEnd" autocomplete="off" class="layui-input">
					</div>
				</div>
				<!-- 加上事件 -->
					<!-- 加上事件 -->
				<script type="text/javascript">
					$(function(){
						$("#activeTimeStart").blur(checkactiveStart)
						var activeName=$("#activeTimeStart").val();
					
					})
				function checkactiveStart(){
						var activeName=$("#activeTimeStart").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script>
				<!--  end-->
						<!-- 加上事件 -->
				<script type="text/javascript">
					$(function(){
						$("#activeTimeEnd").blur(checkactiveEnd)
						var activeName=$("#activeTimeEnd").val();
					
					})
				function checkactiveEnd(){
						var activeName=$("#activeTimeEnd").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script>
				<!--  end-->
				<!--  end-->
				<!-- <div class="layui-form-item">
					<label class="layui-form-label" >活动人数</label>
					<div class="layui-input-block">
						<input type="text" name="password2"  id="activeNum" autocomplete="off" class="layui-input">
					</div>
				</div>
				加上事件
				<script type="text/javascript">
					$(function(){
						$("#activeNum").blur(checkactiveNum)
						var activeName=$("#activeNum").val();
					
					})
				function checkactiveNum(){
						var activeName=$("#activeNum").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script> -->
				<!--  end-->
				<div class="layui-form-item">
					<label class="layui-form-label" >描述</label>
					<div class="layui-input-block">
						<textarea name="activeText" class="layui-textarea" id="activeText"></textarea>
					</div>
				</div>
				<!-- 加上事件 -->
				<script type="text/javascript">
					$(function(){
						$("#activeText").blur(checkactiveText)
						var activeName=$("#activeText").val();
					
					})
				function checkactiveText(){
						var activeName=$("#activeText").val();
						
						if(activeName=="")
							{messageBox ("内容不得为空");}
					}
				
				</script>
				<!--  end-->
				
				
				<div class="layui-form-item">
					<div class="layui-input-block">
						<submit class="layui-btn"  id="buttion" lay-submit lay-filter="submitBut">立即提交</submit>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
				
			</form>
			
			<script type="text/javascript">
					$(function(){
						$("#buttion").click(function(){
							
							$("#addForm").submit();
							
						})
						
						
					})
			
				</script>
			<script>
				layui.use(['upload','form'], function() {
					var form = layui.form;
					var upload = layui.upload;
					var layer = layui.layer;
					//监听提交
					form.on('submit(submitBut)', function(data) {
						return false;
					});
					form.verify({
						//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
					  	ZHCheck: [
						    /^[\u0391-\uFFE5]+$/
						    ,'只允许输入中文'
					  	] 
					});
					//拖拽上传
					upload.render({
						elem: '#goodsPic',
						url: '/upload/',
						done: function(res) {
						  	console.log(res)
						}
					});
				});
			</script>

		</div>
	</body>

</html>